package xiazai;

import java.io.*;
import java.net.Socket;

public class ServerThread implements Runnable{
    private Socket socket;

    public ServerThread() {
    }

    public ServerThread(Socket socket) {
        this.socket = socket;
    }

    @Override
    public void run() {
        try {
            InputStream is = new FileInputStream("/Users/edy/Desktop/file/1.txt");
            OutputStream os = socket.getOutputStream();
            int len;
            byte[] bytes = new byte[1024];
            while ((len = is.read(bytes)) > 0) {
                os.write(bytes);
            }
            socket.shutdownOutput();


        } catch (FileNotFoundException e) {

        } catch (IOException e) {
            e.printStackTrace();
        }

    }
}
